import random

num = random.randint(1, 100)
flag = True
count = 0
while flag:
    inp_num = int(input("请输入数字"))
    count += 1
    if inp_num == num:
        print("恭喜你猜对了")
        flag = False
    else:
        if inp_num > num:
            print("输入的数字大了")
        else:
            print("输入的数字小了")

print(f"一共猜了{count}次")
